var path = require('path');
var fs = require('fs');
exports.mkdirs = function(pathname,callback){
    var root = path.dirname(module.parent.filename);
    pathname = path.isAbsolute(pathname)?pathname:path.join(__dirname,pathname);
    relativepath = path.relative(__dirname,pathname); 
    var folders = relativepath.split(path.sep);
    try {  
    var pre = ''; 
    folders.forEach(folder =>{ 
    try {
    //如果不存在则报错
    fs.statSync(path.join(__dirname,pre,folder));
    } catch (error) {
    fs.mkdirSync(path.join(__dirname,pre,folder));
    }
    pre = path.join(pre, folder);
    });
     
    callback && callback(null);
    } catch (error) {
    callback && callback(error);
    }
}